#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#define debug false
using namespace std;
/*
orgin:
"4","|3","(","|)","3","|=","6","#","|","_|","|<","|_","|\/|",
"|\|","0","|0","(,)","|?","5","7","|_|","\/","\/\/","><","-/","2"
to be:
"4","|3","(","|)","3","|=","6","#","|","_|","|<","|_","|\\\/|",
"|\\|","0","|0","(,)","|?","5","7","|_|","\\\/","\\\/\\\/","><","-\/","2"
*/
string word[]={"4","|3","(","|)","3","|=","6","#","|","_|","|<","|_","|\\/|",
"|\\|","0","|0","(,)","|?","5","7","|_|","\\/","\\/\\/","><","-/","2"};

map<string, int> lib;
map<string, int>::iterator pos;

char ss[110];
string sstr;
int  ans[1100];
int  length[30], len;

void deal()
{
    int i, j, pt, len;
    string tmp;
    
    memset(ans, 0, sizeof(ans));
    len = sstr.size();
    ans[0] = 1;
    
    for (i=1; i<=len; ++i)
    {
        pt = i-1;
        for (j=0; j<26; ++j)
            if (length[j] <= i)
            {
                tmp = string(&sstr[i-length[j]], &sstr[i]);
                if (tmp==word[j])
                   ans[i] += ans[i-length[j]];
            }        
    }      
   
    
}    

void init()
{
    int i;
    sstr = "";
    len = strlen(ss);
    for (i=0; i<len; ++i)
       sstr += word[ss[i]-'A'];
    if (debug)
       printf("The search str is %s\n", sstr.c_str());
}    

bool in()
{
    scanf("%s", ss);
    if (ss[0]=='e') return false;
    return true;    
}    

void buildlib()
{
    int i, j;
    for (i=0; i<26; ++i)
    {
        lib[word[i]] = 1;
        length[i] = word[i].size();
    }    
}    

int main()
{
    if (debug)
    {
        printf("%d", (word[1].find(word[2])) );
    }    
    buildlib();
    while (in())
    {
        init();
        deal(); 
        printf("%d\n", ans[sstr.size()]);
    }    
   
    return 0;    
}    
